package org.csu.demo.nettydemo;

import org.csu.demo.nettydemo.server.WebSocketServer;
import org.csu.demo.nettydemo.utils.NetworkUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@MapperScan("org.csu.demo.nettydemo.persistence")
public class NettyDemoApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(NettyDemoApplication.class, args);
        Environment env = application.getEnvironment();
        String host = NetworkUtils.getLocalIpAddress();
        String port = env.getProperty("server.port");
        System.out.println("[----------------------------------------------------------]");
        System.out.println("聊天室启动成功！点击进入:\t http://" + host + ":" + port);
        System.out.println("[----------------------------------------------------------");
        WebSocketServer.inst().run(53134);
    }
}
